<include file="Public/min-header" />
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
	<style type="text/css">
		th{text-align: center;background: #eee;}
	</style>
    <include file="Public/breadcrumb"/> 
	<section class="content">
       <div>
       		<div class="col-xs-12">
	       		<div class="box">
	             <div class="box-header">
	             <div>
  					<div>
						<!--
						<div class="navbar margin">
						        <form action="" id="search-form2" class="navbar-form form-inline" method="get" style="padding: 0">
						                                <div class="form-group">
						                                    <div class="input-group">
						                                        <input type="text" name="consignee" id="consignee" placeholder="客户/客户店铺" id="input-member-id" class="form-control" style="width:150px;" value="{:I('consignee')}">
						                                    </div>
						                                </div>
						                                <div class="form-group">
						                                    <div class="input-group">
						                                        <input type="text" name="return_order_sn" id="return_order_sn" placeholder="订单号搜索" id="input-return_order_sn" class="form-control" style="width:150px;" value="{:I('return_order_sn')}">
						                                    </div>
						                                </div>
												<div class="form-group">
						                                    <div class="input-group">
						                                        <input type="text" name="order_sn" id="order_sn" placeholder="原订单号搜索" id="input-order-id" class="form-control" style="width:150px;" value="{:I('order_sn')}">
						                                    </div>
						                                </div>
						                                <div class="form-group">
						                                    <div class="input-group" style="width: 300px;">
						                                      <div class="input-group-addon" style="width:35%;">
						                                       		选择时间  <i class="fa fa-calendar"></i>
						                                      </div>
						                                      <input type="text" class="form-control" name="timegap" value="{:I('timegap')}" id="start_time" autocomplete="off" style="width:250px;">
						                                      </div>
						                                </div>
						                                <div class="form-group">
						                                    <select name="status" id="status" class="form-control" style="width:110px;">
						                                    	<if condition="$vo['status'] eq '0'">
						                                    		<?php
						                                    			if(I("status")=="0"){
						                                    		?>
						                                        	<option value="">扣费状态</option>
						                                            <option value="0" selected="selected">未审核</option>
						                                            <option value="1">已审核</option>
						                                    		<option value="2">已扣费</option>
																	<option value="3">已取消</option>
																	<?php
						                                    	}elseif(I("status")=="1"){
						                                    	?>
																	<option value="">扣费状态</option>
																	<option value="0">未扣费</option>
																	<option value="1" selected="selected">已审核</option>
																	<option value="2" >已扣费</option>
																	<option value="3">已取消</option>
						                                    	<?php
						                                    	}elseif(I("status")=="2"){
						                                    	?>
						                                    		<option value="">扣费状态</option>
						                                    		<option value="0">未扣费</option>
																	<option value="1" >已审核</option>
						                                    		<option value="2" selected="selected">已扣费</option>
																	<option value="3">已取消</option>
																	<?php
						                                    	}elseif(I("status")=="3"){
						                                    	?>
																	<option value="">扣费状态</option>
																	<option value="0">未扣费</option>
																	<option value="1" >已审核</option>
																	<option value="2">已扣费</option>
																	<option value="3" selected="selected">已取消</option>
						                                    	<?php
						                                    	}else{
						                                    	?>
						                                    	<option value="">扣费状态</option>
						                                    	<option value="0">未扣费</option>
						                                    	<option value="2">已扣费</option>
																<option value="3">已取消</option>
						                                    	<?php
						                                    	}
						                                    	?>
						                                    </select>
						                                </div>
									<div class="form-group">
										<select name="getorder" id="getorder" class="input-sm" style="width:100px;">
											<if condition="$vo['getorder'] eq '0'">
												<?php
																		if(I("getorder")=="0"){
																	?>
												<option value="">取货状态</option>
												<option value="0" selected="selected">未审取货</option>
												<option value="1">已取货</option>
												<option value="2">未入库</option>
												<?php
																}elseif(I("getorder")=="1"){
																?>
												<option value="">取货状态</option>
												<option value="0">未审取货</option>
												<option value="1"  selected="selected">已取货</option>
												<option value="2"  >未入库</option>
												<?php
																}elseif(I("getorder")=="2"){
																?>
												<option value="">取货状态</option>
												<option value="0">未审取货</option>
												<option value="1">已取货</option>
												<option value="2" selected="selected" >未入库</option>
												<?php
																}else{
																?>
												<option value="">取货状态</option>
												<option value="0">未审取货</option>
												<option value="1">已取货</option>
												<option value="2">未入库</option>
												<?php
																}
																?>
										</select>
									</div>
														<div class="form-group" style="margin-left:13px;">
															<input class="btn btn-primary" type="submit" value="确定">
														</div>
														<button type="button" class="btn btn-primary pull-right" id="daochu"><i class="fa fa-file-excel-o"></i>&nbsp;导出excel</button>
						                            </form>
						                    </div>
						                    -->
                 	</div>
		  		 </div>
	             </div><!-- /.box-header -->
	             <div class="box-body">
	           	 <div>
	            	<div class="margin">
		              <table id="list-table" class="table table-bordered table-striped dataTable" role="grid" aria-describedby="example1_info">
		                 <thead>
		                   <tr role="row">
                               <th class="sorting" align="center">单号</th>
                               <th class="sorting" align="center">原单号</th>
                               <th class="sorting" align="center">区域</th>
                               <th class="sorting" align="center">备注</th>
							   <th class="sorting" align="center">类型</th>
							   <th class="sorting" align="center">买家</th>
			                   <th class="sorting" align="center">产品名称</th>
			                   <th class="sorting" align="center">单价</th>
			                   <th class="sorting" align="center">数量</th>
							   <th class="sorting" align="center">订单价</th>
			                   <th class="sorting" align="center">平台扣点</th>
							   <th class="sorting" align="center">应扣金额</th>
							   <th class="sorting" align="center">退货时间</th>
							   <th class="sorting" align="center">操作</th>
		                   </tr>
		                 </thead>
						<tbody>
							<?php
							$heji_ptprices=0;
							?>
                         <foreach name="orderList" item="vo" key="k" >
							 <?php
							 $dsprice=(float)$vo['member_goods_price']*(float)$vo['goods_num']; //订单价
							 $ptprice=$dsprice*($vo['points']/100); //平台价
							 $ptprices=$dsprice-$ptprice;
							 $heji_ptprice+=$ptprice;
							 $heji_ptprices+=$ptprices;
							 ?>
                          <tr role="row" align="center">
                             <td><a href="javascript:" id="chakan" rel="{$vo.order_id}">{$vo.return_order_sn}</a></td>
                             <td>{$vo.order_sn}</td>
                             <td>{$vo.fenbu_name}</td>
							 <td>{$vo.remark}</td>
							  <td class="status">{$vo['refund_type']==0?'退货':'退货退款'}</td>
							 <td>{$vo.company}</td>
                             <td>{$vo.goods_name}({$vo.key_name})</td>
							 <td>{:is_intval($vo['member_goods_price'])}</td>
							 <td>{$vo.goods_num}</td>
		                     <td style="color:#f39c12;">{:is_intval($dsprice)}</td>
		                     <td style="color: green;">{:is_intval($ptprice)}</td>
		                     <td style="color:red;">{:is_intval($ptprices)}</td>
		                     <td>{$vo.tuihuo_time|date='Y-m-d',###}</td>
							 <td>
								 <if condition="$vo['store_status'] eq '0'">
								 <a href="javascript:void(0);" onclick="update_return_store_status(this)" data-id="{$vo.id}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="确认退货">确认退货</a>
								 </if>
								 <!--
								 <a href="/index.php?m=seller&c=Order&a=tuihuo_edit_order&id={$vo.id}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="查看详情"><i class="fa fa-eye">查看</i></a>
							 		-->
							 </td>
		                   </tr>
		                  </foreach>
						  <tr>
							  <td colspan="10" style="font-weight: bold;text-align: right;">合计：</td>
							  <td style="text-align: center;color: red;font-size: 16px;">{:is_intval($heji_ptprice)}</td>
							  <td style="text-align: center;color: red;font-size: 16px;">{:is_intval($heji_ptprices)}</td>
						  </tr>
		                   </tbody>
		                 <tfoot>
		                 </tfoot>
		               </table>
	               </div>
	          </div>
              <div class="row">
              	    <div class="col-sm-6 text-left"></div>
                    <div class="col-sm-6 text-right">{$page}</div>		
              </div>
	          </div>
	        </div>
       	</div>
       </div>
   </section>
</div>
<script type="text/javascript">
$(document).ready(function() {
	$('#start_time').daterangepicker({
			format:"YYYY-MM-DD HH:mm",
			singleDatePicker: false,
			showDropdowns: true,
			minDate:'2021-01-01 00:00',
			maxDate:'2030-01-01 00:00',
			startDate:'{:date("Y-m-d")} 00:00',
	        showWeekNumbers: true,
	        timePicker: true,
	        timePickerIncrement: 1,
	        timePicker12Hour: false,
	        opens: 'right',
	        buttonClasses: ['btn btn-default'],
	        applyClass: 'btn-small btn-primary',
	        cancelClass: 'btn-small',
		    locale : {
	            applyLabel : '确定',
	            cancelLabel : '取消',
	            fromLabel : '起始时间',
	            toLabel : '结束时间',
	            customRangeLabel : '自定义',
	            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
	            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
	            firstDay : 1
	        }
	});
	$("#list-table #chakan").click(function(){
			var myrel=$(this).attr('rel');
			var myrul='/index.php/seller/order/detail/order_id/'+myrel;//+myrel;
				layer.open({
				  type: 2,
				  title:'订单信息',
				  shadeClose: true, //点击遮罩关闭
				  skin: 'layui-layer-rim', //加上边框
				  area: ['920px', '620px'], //宽高
				  content: myrul
			})
	    });
		$("#daochu").click(function(){
			var order_sn=$("#order_sn").val();
			var consignee=$("#consignee").val();
			var timegap=$("#start_time").val(); 
			var order_status=$("#status").val();
			var getorder=$("#getorder").val();
			var return_order_sn=$("#return_order_sn").val();
			location.href="/index.php/Seller/order/export_order_tuihuo?order_sn="+order_sn+"&consignee="+consignee+"&timegap="+timegap+"&status="+order_status+"&getorder="+getorder+"&return_order_sn="+return_order_sn;
		})
});

//更新退货状态
function update_return_store_status(e) {
	var id = $(e).data('id');
	// $(e).hide();
	$.ajax({
		url: "/index.php/Seller/order/create_return_goods",
		type: "post",
		data: {
			id: id
		},
		dataType: "json",
		success: function (data) {
			if (data.status == 1) {
				$(e).closest('tr').remove();
				return layer.msg(data.msg);
			}
			return layer.msg(data.msg);
		}
	})
}
</script>
</body>
</html>